package org.ch00.test10;

import java.util.concurrent.TimeUnit;

/*
 *
 *@author XCH
 *@date 2025 - 03 - 11 - 11:47
 *
 */
public class DataThread extends Thread{
    @Override
    public void run() {
        System.out.println("线程开始...");
        while (true) {
            boolean flag = Thread.currentThread().isInterrupted();
            try {
//                Thread.sleep(2000);
                TimeUnit.SECONDS.sleep(2);
                System.out.println("数据采集");
            } catch (InterruptedException e) {
                System.out.println("线程被中断，准备退出...");
                Thread.currentThread().interrupt();
                break;
            }
        }
        System.out.println("线程结束...");
    }
}
